<?php

namespace App\Filament\Resources;

use App\Filament\Resources\MemberResource\Pages;
use App\Filament\Resources\MemberResource\RelationManagers;
use App\Models\Member;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Columns\Layout\Split;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Illuminate\Database\Eloquent\Model;
use Filament\Tables\Columns\ImageColumn;
use Filament\Tables\Columns\TextColumn;
class MemberResource extends Resource
{
    protected static ?string $model = Member::class;

    protected static ?string $navigationIcon = 'heroicon-o-user';

    protected static ?string $label = '会员';



    public static function form(Form $form): Form
    {
        return $form
            ->schema([
                //
            ]);
    }

    public static function table(Table $table): Table
    {
        return $table
            ->searchable()
            ->defaultPaginationPageOption(25)
            ->recordUrl(fn (Model $record): string => route('filament.admin.resources.members.edit', ['record' => $record]))
            ->columns([
                //
                Split::make([
                    ImageColumn::make('profile_photo_path')
                        ->checkFileExistence(false)
                        ->defaultImageUrl(url('avatar.jpg'))
                        ->circular()
                        ->grow(false),
                    TextColumn::make('name'),
                    TextColumn::make('phone')
                        ->placeholder('暂无数据.')
                        ->label('手机号'),
                    TextColumn::make('address')
                        ->placeholder('暂无数据.')
                        ->label('地址'),
                ]),

            ])
            ->filters([
                //
            ])
            ->actions([
                //Tables\Actions\EditAction::make(),
            ])
            ->bulkActions([
                Tables\Actions\BulkActionGroup::make([
                   // Tables\Actions\DeleteBulkAction::make(),
                ]),
            ]);
    }

    public static function getRelations(): array
    {
        return [
            //
        ];
    }

    public static function getPages(): array
    {
        return [
            'index' => Pages\ListMembers::route('/'),
            'create' => Pages\CreateMember::route('/create'),
            'edit' => Pages\EditMember::route('/{record}/edit'),
        ];
    }
}
